package com.lx.note.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * User: Administrator
 * Date: 2018/06/04 下午 9:40
 */

@Component
@Aspect
public class TimeAspect {
//    @Around("bean(userService)")
//    @Around("within(com.lx.*.service.impl.*Impl)")
    @Around("execution(* com.lx.*.service.*.*.login(..))")
    public Object test(ProceedingJoinPoint jp)throws Throwable{
        //使用jp的获取 方法签名 的方法获取方法信息
        Signature sig = jp.getSignature();
        //测试业务方法的性能
        long l1 = System.currentTimeMillis();
        Object val = jp.proceed();
        long l2 = System.currentTimeMillis();
        System.out.println(sig +" 耗时: " + (l2-l1));
        return val;


    }


}
